#include "widget.h"
#include "ui_widget.h"
#include <QMessageBox>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    // 给每个输入框 设置相关属性
    ui->lineEdit_account->setPlaceholderText("输入账号/用户名"); // 设置默认提示信息
    ui->lineEdit_account->setClearButtonEnabled(true); // 设置一键删除

    ui->lineEdit_password->setPlaceholderText("输入密码");
    ui->lineEdit_password->setClearButtonEnabled(true);
    ui->lineEdit_password->setEchoMode(QLineEdit::Password); // 将显示模式设置为密码

    ui->lineEdit_email->setPlaceholderText("输入邮箱");
    ui->lineEdit_email->setClearButtonEnabled(true);
    ui->lineEdit_email->setInputMask("XXXXXXXXXXXXXXX.com"); // 设置格式条件

}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    QString account = ui->lineEdit_account->text();
    QString password = ui->lineEdit_password->text();
    QString email = ui->lineEdit_email->text();
    QString gender = ui->radioButton_male->isChecked() ? "男" : "女";

    // 创建一个弹出窗口来显示填入的信息
    QMessageBox msgBox;
    msgBox.setText("账号/用户名: " + account + "\n"
                  + "密码: " + password + "\n"
                  + "邮箱: " + email + "\n"
                  + "性别: " + gender);
    msgBox.exec();
}
